package com.company.project.core;

import org.springframework.stereotype.Controller;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * IntelliJ IDEA.
 * User: lwb
 * Date: 2017/10/18
 * Time: 15:14
 * function:
 */
public class BaseController {

    public MsgMap getMsgMap()
    {
        MsgMap msg = new MsgMap();
        msg.putCode(MsgCode.SUCCESS);
        return  msg;
    }

    /**
     * 得到ModelAndView
     */
    public ModelAndView getModelAndView()
    {
        return new ModelAndView();
    }

    /**
     * 得到request对象
     */
    public HttpServletRequest getRequest()
    {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        return request;
    }

}
